﻿/**
 * Copyright (C) 2012-2013 original author and authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using CGLib;

namespace NGuice.Inject.Internal
{
    //TODO:选择字节码动态生成库，实现cglib类似功能!

    /// <summary>
    /// 此类用于运行时字节码生成的工具类，此类从Guice中移植而来，Guice中使用了cglib库的FastClass用于
    /// 快速反射类，使用了Enhancer用于方法拦截和代理循环依赖。但在.NET中没有cglib类似库，因此，将使用
    /// 以下三种方案解决此问题，在后续版本中将持续比较这三种方案的性能
    /// <list type="ul">
    /// 1、使用Mono Cecil库实现动态代理，并最终实现Enhancer类似的类结构
    /// 2、使用Emit实现动态代理，并最终实现Enhancer类似的类结构
    /// 3、使用Castle DynamicProxy库实现动态代理并实现Enhancer类似的类结构
    /// </list>
    /// <remarks>TODO:为了尽快发布版本，Version1.0首先采用Castle DynamicProxy库实现，将来版本将逐步替换成Emit或cecil实现</remarks>
    /// </summary>
    public sealed class BytecodeGen
    {
        /// <summary>
        /// 加载并返回指定类型的程序集，如果使用当前程序集，则返回null
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static Assembly GetLoader(Type type)
        {
            //TODO:实现程序集加载
            return null;
        }

        public static FastClass NewFastClass(Type type)
        {
            return FastClass.Create(type);
        }
    }
}
